<?php
include_once 'head.php';
?>

<head>
    <meta charset="utf-8" />
    <title><?php echo $text['title'] ?></title>
    <link rel="stylesheet" href="Style/css/index.css?LikeGirl=<?php echo $version ?>">
    <style>
        .admin-link {
            color: inherit;
            text-decoration: none;
        }
        .admin-link:hover {
            color: #666;
            text-decoration: none;
        }
        /* 更新日志模态框样式 */
        .changelog-modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0,0,0,0.4);
        }
        .changelog-content {
            background-color: #fefefe;
            margin: 5% auto;
            padding: 20px;
            border-radius: 8px;
            width: 80%;
            max-width: 800px;
            max-height: 80vh;
            overflow-y: auto;
        }
        .close-changelog {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
            cursor: pointer;
        }
        .close-changelog:hover {
            color: black;
        }
        .changelog-version {
            margin-top: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }
        .changelog-version h3 {
            color: #333;
            margin-bottom: 10px;
        }
        .changelog-badge {
            display: inline-block;
            background-color: #ff6b6b;
            color: white;
            font-size: 12px;
            padding: 2px 8px;
            border-radius: 10px;
            margin-left: 10px;
            vertical-align: middle;
        }
    </style>
</head>

<body>
    <div id="pjax-container">

        
        <!-- 时间区域 -->
        <div class="time">
            <span id="span_dt_dt"></span>
            <b id="tian"></b>
            <b id="shi"></b>
            <b id="fen"></b>
            <b id="miao"></b>
        </div>
        <!-- 卡片区域 -->
        <div class="card-wrap">
            <div class="row central">
                <!-- 第一行三个小卡片 -->
                <div class="card col-lg-4 col-sm-12 col-sm-x-12 flex-h <?php if ($text['Animation'] == "1") { echo 'animated fadeInUp'; } ?>">
                    <img src="Style/img/home/home-page.svg">
                    <div class="text">
                        <span><a target="_self" href="little.php"><?php echo $text['card1'] ?></a></span>
                        <p><?php echo $text['deci1'] ?></p>
                    </div>
                </div>
                <div class="card col-lg-4 col-sm-12 col-sm-x-12 flex-h <?php if ($text['Animation'] == "1") { echo 'animated fadeInUp'; } ?>">
                    <img src="Style/img/home/home-msg.svg" alt="">
                    <div class="text">
                        <span><a target="_self" href="leaving.php"><?php echo $text['card2'] ?></a></span>
                        <p><?php echo $text['deci2'] ?></p>
                    </div>
                </div>
                <div class="card col-lg-4 col-sm-12 col-sm-x-12 flex-h <?php if ($text['Animation'] == "1") { echo 'animated fadeInUp'; } ?>">
                    <img src="Style/img/home/home-about.svg" alt="">
                    <div class="text">
                        <span><a target="_self" href="about.php"><?php echo $text['card3'] ?></a></span>
                        <p><?php echo $text['deci3'] ?></p>
                    </div>
                </div>
                
                <!-- 第二行两个中等卡片 -->
                <div class="card-b col-lg-6 col-12 col-sm-12 flex-h <?php if ($text['Animation'] == "1") { echo 'animated fadeInUp'; } ?>">
                    <img src="Style/img/home/home-photo.svg" alt="">
                    <div class="text">
                        <span><a target="_self" href="loveImg.php">Our Photo</a></span>
                        <p>珍贵相册 记录瞬间</p>
                    </div>
                </div>
                <div class="card-b col-lg-6 col-12 col-sm-12 flex-h <?php if ($text['Animation'] == "1") { echo 'animated fadeInUp'; } ?>">
                    <img src="Style/img/home/home-list.svg" alt="">
                    <div class="text">
                        <span><a target="_self" href="list.php">Covenant List</a></span>
                        <p>愿望列表 你我之间的约定</p>
                    </div>
                </div>
                
                <!-- 更新日志卡片 - 修复点击事件 -->
                <div class="card-b col-lg-12 col-12 col-sm-12 flex-h <?php if ($text['Animation'] == "1") { echo 'animated fadeInUp'; } ?>">
                    <img src="Style/img/home/home-list.svg" alt="">
                    <div class="text">
                        <span>
                            <a href="changelog.php">更新日志</a>
                            <a href="javascript:void(0)" id="quickViewLink" style="margin-left: 10px; font-size: 14px; color: #666;" onclick="event.stopPropagation();">[快速查看最新版本]</a>
                        </span>
                        <p>查看系统最新功能和改进</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 快速查看模态框 - 只显示最新版本 -->
    <div id="changelogModal" class="changelog-modal">
        <div class="changelog-content">
            <span class="close-changelog">&times;</span>
            <h2>最新版本更新</h2>
            
            <div class="changelog-version">
                <h3>版本 1.0.2 (2025-03-24)</h3>
                <h4>主要改进</h4>
                <ul>
                    <li><strong>全新编辑器界面</strong> - 重新设计了编辑器界面，采用左侧编辑、右侧大纲的分栏布局</li>
                    <li><strong>本地存储功能</strong> - 添加了自动保存草稿功能，防止刷新页面导致内容丢失</li>
                    <li><strong>快捷键支持</strong> - 添加了丰富的编辑快捷键，如Ctrl+1~6设置标题级别</li>
                    <li><strong>工具栏增强</strong> - 重新设计了工具栏，提供更直观的编辑按钮</li>
                    <li><strong>用户体验优化</strong> - 添加了草稿状态提示，显示最近保存时间</li>
                </ul>
            </div>
            
            <div style="margin-top: 20px; text-align: center;">
                <a href="changelog.php" style="color: #666; text-decoration: underline;">查看完整更新历史</a>
            </div>
        </div>
    </div>

    <?php
    include_once 'footer.php';
    ?>

    <script>
        // 完全重写快速查看功能，确保可靠性
        document.addEventListener('DOMContentLoaded', function() {
            // 获取DOM元素
            var modal = document.getElementById('changelogModal');
            var quickViewLink = document.getElementById('quickViewLink');
            var closeBtn = document.getElementsByClassName('close-changelog')[0];
            var fullHistoryLink = modal.querySelector('a[href="changelog.php"]');
            
            // 确保模态框初始状态为隐藏
            if (modal) {
                modal.style.display = "none";
            }
            
            // 显示模态框的函数
            function openModal(e) {
                if (e) {
                    e.preventDefault();
                    e.stopPropagation();
                }
                if (modal) {
                    modal.style.display = "block";
                    console.log('模态框已打开');
                }
            }
            
            // 关闭模态框的函数
            function closeModal() {
                if (modal) {
                    modal.style.display = "none";
                    console.log('模态框已关闭');
                }
            }
            
            // 绑定事件 - 使用事件委托以提高可靠性
            if (quickViewLink) {
                // 移除可能存在的内联onclick属性
                quickViewLink.removeAttribute('onclick');
                
                // 添加新的事件监听器
                quickViewLink.addEventListener('click', function(e) {
                    openModal(e);
                    return false; // 阻止默认行为
                });
                
                console.log('快速查看链接事件已绑定');
            }
            
            // 关闭按钮事件
            if (closeBtn) {
                closeBtn.addEventListener('click', closeModal);
            }
            
            // 点击模态框外部关闭
            window.addEventListener('click', function(e) {
                if (e.target === modal) {
                    closeModal();
                }
            });
            
            // ESC键关闭
            document.addEventListener('keydown', function(e) {
                if (e.key === "Escape" && modal && modal.style.display === "block") {
                    closeModal();
                }
            });
            
            // 完整历史链接事件
            if (fullHistoryLink) {
                fullHistoryLink.addEventListener('click', function() {
                    closeModal(); // 先关闭模态框
                    // 默认行为继续（跳转到changelog.php）
                });
            }
            
            // 检查是否从更新日志页面返回
            if (localStorage.getItem('visitedChangelog') === 'true') {
                // 清除标记
                localStorage.removeItem('visitedChangelog');
                console.log('检测到从更新日志页面返回');
            }
            
            console.log('快速查看功能初始化完成');
        });
    </script>
</body>

</html>